package cn.tedu.rabbitmqboot.m4;


import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;

// 路由模式

@SpringBootApplication
public class Main {
    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange("direct_logs", false, false);
    }

    @Autowired
    private Producer producer;

    @PostConstruct
    public void test() {
        new Thread(() -> producer.send()).start();  //lambda 表达式
    }
}
